package logic

import (
	"context"
	"doc-manage/models/mysql"
	"errors"

	"doc-manage/doctorrpc/doctorrpc"
	"doc-manage/doctorrpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type DoctorUpdateLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDoctorUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DoctorUpdateLogic {
	return &DoctorUpdateLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 修改方法
func (l *DoctorUpdateLogic) DoctorUpdate(in *doctorrpc.DoctorUpdateRequest) (*doctorrpc.DoctorUpdateResponse, error) {
	// todo: add your logic here and delete this line

	var doctor mysql.Doctor

	err := doctor.DoctorUpdate(mysql.DB, in)
	if err != nil {
		return nil, errors.New("修改失败")
	}

	return &doctorrpc.DoctorUpdateResponse{
		DoctorId: in.DoctorId,
	}, nil
}
